//生产环境中 静态资源的处理
module.exports = function () {

  // let devHost = '//localhost:9001';
  let devHost = '//localhost:9002'; //←静态资源现在是由wds提供的。

  let jsFiles = ['libs.js','main.js'];
  let cssFiles = ['main.css'];

  const assets = {
    js: [],
    css: []
  };
  if (!__IS_PROD__) {//开发环境
    assets.js.push(`<script type="text/javascript"  src="${devHost}/libs.js"></script>`);
    assets.js.push(`<script type="text/javascript"  src="${devHost}/main.js"></script>`);
    assets.css.push(`<link rel="stylesheet" type="text/css" href="${devHost}/main.css" />`);
  } else {
    //生产环境 从 asset-manifest.json 读取资源
    const map = require('@dist/server/asset-manifest.json');
    /*
      {
        "libs.js": "/js/libs.00849470.js",
        "main.css": "/css/main.ca28e53a.css",
        "main.js": "/js/main.c75edf3a.js",
        "img/img.f9bd91f4.jpg": "/img/img.f9bd91f4.jpg"
      }
    */
    jsFiles.forEach(item => {
      if(map[item])
        assets.js.push(`<script type="text/javascript"  src="${map[item]}"></script>`)
    });
    cssFiles.forEach(item => {
      if(map[item])
        assets.css.push(`<link rel="stylesheet" type="text/css" href="${map[item]}" />`)
    });
  }


  return assets;

}
